package no.ntnu.fp.gui.guiElements;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;

public class CalendarPanel extends JPanel {

	private JTable table;

	public CalendarPanel() {
		super();
		setBackground(Color.LIGHT_GRAY);
		setBorder(UIManager.getBorder("PasswordField.border"));
		setBounds(131, 74, 520, 356);

		table = new JTable();
		table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		table.setCellSelectionEnabled(true);
		table.setColumnSelectionAllowed(true);

		table.setModel(new DefaultTableModel(new Object[][] {
				{ "06:00", null, null, null, null, null, null, null },
				{ "07:00", null, null, null, null, null, null, null },
				{ "08:00", null, null, null, null, null, null, null },
				{ "09:00", null, null, null, null, null, null, null },
				{ "10:00", null, null, null, null, null, null, null },
				{ "11:00", null, null, null, null, null, null, null },
				{ "12:00", null, null, null, null, null, null, null },
				{ "13:00", null, null, null, null, null, null, null },
				{ "14:00", null, null, null, null, null, null, null },
				{ "15:00", null, null, null, null, null, null, null },
				{ "16:00", null, null, null, null, null, null, null },
				{ "17:00", null, null, null, null, null, null, null },
				{ "18:00", null, null, null, null, null, null, null },
				{ "19:00", null, null, null, null, null, null, null },
				{ "20:00", null, null, null, null, null, null, null },
				{ "21:00", null, null, null, null, null, null, null },
				{ null, null, null, null, null, null, null, null }, },
				new String[] { "Kl.", "Fredag", "L\u00F8rdag", "S\u00F8ndag",
						"Mandag", "Tirsdag", "Onsdag", "Torsdag" }) {
			boolean[] columnEditables = new boolean[] { false, false, false,
					false, false, false, false, false };

			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(0).setResizable(false);
		table.getColumnModel().getColumn(0).setPreferredWidth(36);
		table.getColumnModel().getColumn(1).setResizable(false);
		table.getColumnModel().getColumn(2).setResizable(false);
		table.getColumnModel().getColumn(3).setResizable(false);
		table.getColumnModel().getColumn(4).setResizable(false);
		table.getColumnModel().getColumn(5).setResizable(false);
		table.getColumnModel().getColumn(6).setResizable(false);
		table.getColumnModel().getColumn(7).setResizable(false);
		table.setBounds(10, 54, 502, 270);
		add(table);
		table.setBackground(Color.WHITE);

		JLabel lblMars = new JLabel("Marsaprilmai");
		lblMars.setBounds(29, 6, 93, 26);
		add(lblMars);
		lblMars.setFont(new Font("Segoe UI", Font.BOLD, 17));

		JLabel lblFredag = new JLabel("Fredag");
		lblFredag.setBounds(59, 28, 36, 21);
		add(lblFredag);

		JLabel lblLrdag = new JLabel("L\u00F8rdag");
		lblLrdag.setBounds(123, 29, 42, 21);
		add(lblLrdag);

		JLabel lblSndag = new JLabel("S\u00F8ndag");
		lblSndag.setBounds(189, 29, 43, 21);
		add(lblSndag);

		JLabel lblMandag = new JLabel("Mandag");
		lblMandag.setBounds(254, 28, 48, 21);
		add(lblMandag);
	}

	public CalendarPanel(Container container) {
		super();
		setBackground(Color.LIGHT_GRAY);
		setBorder(UIManager.getBorder("PasswordField.border"));
		setBounds(131, 74, 520, 356);
		container.add(this);
		setLayout(null);

		table = new JTable();
		table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		table.setCellSelectionEnabled(true);
		table.setColumnSelectionAllowed(true);
		// table

		table.setModel(new DefaultTableModel(new Object[][] {
				{ "06:00", null, null, null, null, null, null, null },
				{ "07:00", null, null, null, null, null, null, null },
				{ "08:00", null, null, null, null, null, null, null },
				{ "09:00", null, null, null, null, null, null, null },
				{ "10:00", null, null, null, null, null, null, null },
				{ "11:00", null, null, null, null, null, null, null },
				{ "12:00", null, null, null, null, null, null, null },
				{ "13:00", null, null, null, null, null, null, null },
				{ "14:00", null, null, null, null, null, null, null },
				{ "15:00", null, null, null, null, null, null, null },
				{ "16:00", null, null, null, null, null, null, null },
				{ "17:00", null, null, null, null, null, null, null },
				{ "18:00", null, null, null, null, null, null, null },
				{ "19:00", null, null, null, null, null, null, null },
				{ "20:00", null, null, null, null, null, null, null },
				{ "21:00", null, null, null, null, null, null, null },
				{ null, null, null, null, null, null, null, null }, },
				new String[] { "Kl.", "Fredag", "L\u00F8rdag", "S\u00F8ndag",
						"Mandag", "Tirsdag", "Onsdag", "Torsdag" }) {
			boolean[] columnEditables = new boolean[] { false, false, false,
					false, false, false, false, false };

			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(0).setResizable(false);
		table.getColumnModel().getColumn(0).setPreferredWidth(36);
		table.getColumnModel().getColumn(1).setResizable(false);
		table.getColumnModel().getColumn(2).setResizable(false);
		table.getColumnModel().getColumn(3).setResizable(false);
		table.getColumnModel().getColumn(4).setResizable(false);
		table.getColumnModel().getColumn(5).setResizable(false);
		table.getColumnModel().getColumn(6).setResizable(false);
		table.getColumnModel().getColumn(7).setResizable(false);
		table.setBounds(10, 54, 502, 270);
		add(table);
		table.setBackground(Color.WHITE);

		JLabel lblMars = new JLabel("Mars");
		lblMars.setBounds(29, 6, 93, 26);
		add(lblMars);
		lblMars.setFont(new Font("Segoe UI", Font.BOLD, 17));

		JLabel lblFredag = new JLabel("Fredag");
		lblFredag.setBounds(59, 28, 36, 21);
		add(lblFredag);

		JLabel lblLrdag = new JLabel("L\u00F8rdag");
		lblLrdag.setBounds(123, 29, 42, 21);
		add(lblLrdag);

		JLabel lblSndag = new JLabel("S\u00F8ndag");
		lblSndag.setBounds(189, 29, 43, 21);
		add(lblSndag);

		JLabel lblMandag = new JLabel("Mandag");
		lblMandag.setBounds(254, 28, 48, 21);
		add(lblMandag);

		JLabel lblTirsdag = new JLabel("Tirsdag");
		lblTirsdag.setBounds(321, 28, 42, 21);
		add(lblTirsdag);

		JLabel lblOnsdag = new JLabel("Onsdag");
		lblOnsdag.setBounds(387, 28, 44, 21);
		add(lblOnsdag);

		JLabel lblTorsdag = new JLabel("Torsdag");
		lblTorsdag.setBounds(454, 28, 45, 21);
		add(lblTorsdag);
	}

}